<?php
/*
Extension Name: My Gamer Card
Extension Url: http://lussumo.com/addons/index.php?PostBackAction=AddOn&AddOnID=143
Description: Allows users to add their GamerCard into the user profile page
Version: 1.0.0
Author: ukjay
Author Url: http://www.xboxic.co.uk
 *
 * @copyright @@AUTHOR@@ @@YEAR@@
 * @package Extensions
 * @subpackage MyGamerCard
 * @license  @@LICENCE_URL@@ @@LICENCE@@
 *
 * $Id: default.php 335 2008-11-02 22:44:49Z dinoboff $
 * $HeadURL: http://vanilla-friends.googlecode.com/svn/trunk/MyGamerCard/default.php $
 */

/**
 * @global Context $Context
 * @global Head $Head
 */
global $Context, $Head;


// Define the required Customizations for this extension
$Context->Configuration['CUSTOMIZATION_GAMERCARD'] = '';
$Context->SetDefinition('CUSTOMIZATION_GAMERCARD', 'Your Gamer Tag');
$Context->SetDefinition('CUSTOMIZATION_GAMERCARD_DESCRIPTION', 'You can add your Gamer Card to your Profil.');
$Context->SetDefinition('MyGameCard_MyGameCard', 'Gamercard &amp; Xbox360 Avatar');
$Context->SetDefinition('MyGameCard_ReadMy360VoiceBlog', 'Read My 360Voice Blog');
$Context->SetDefinition('MyGameCard_SendMeConsoleMessage', 'Send Me a Console Message');

// Attach to the user account being viewed if there is no postback action
if ($Context->SelfUrl == 'account.php'
	&& ForceIncomingString('PostBackAction', '') == ''
) {

	// Render the Card
	function Account_RenderGamerCard(&$Account) {
		$GamerTag = FormatHtmlStringInline($Account->User->Customization('CUSTOMIZATION_GAMERCARD'), 1, 1);
		if ($GamerTag != '') {
			$GamerTag = urlencode($GamerTag);
			echo '<h2>'.$Account->Context->GetDefinition('MyGameCard_MyGameCard').'</h2>
			<div id="MyGamerCard">
			  <table border="0" cellpadding="0" cellspacing="0" width="406" height="115" style="border-collapse: collapse" bordercolor="#111111">
			    <tr>
			      <td width="287" height="80">
			      <img src="http://card.mygamercard.net/nxe/' . $GamerTag . '.png" Width="279" height="127" align="right"></td>
			      <td width="142" rowspan="2" height="115">
			      <img src="http://avatar.xboxlive.com/avatar/' . $GamerTag . '/avatar-body.png" Width="140" height="274"></td>
			    </tr>
			    <tr>
			      <td width="287" height="35">
			      <img src="http://avatar.xboxlive.com/avatar/' . $GamerTag . '/avatarpic-l.png" Width="64" height="64">
			      <p><a href="http://www.360voice.com/tag/' . $GamerTag . '">'
						. $Account->Context->GetDefinition('MyGameCard_ReadMy360VoiceBlog')
						. '</a></p>
			      <p><a href="http://live.xbox.com/en-GB/profile/MessageCenter/SendMessage.aspx?gt=' . $GamerTag . '">'
						. $Account->Context->GetDefinition('MyGameCard_SendMeConsoleMessage')
						.'</a></p></td>
			    </tr>
			  </table>
			</div>
';
		}
	}

	$Context->AddToDelegate('Account', 'PostProfileRender', 'Account_RenderGamerCard');

	$Head->AddString('<style type="text/css">
	<!--
	' . file_get_contents(dirname(__FILE__). '/style.css') . '
	-->
	</style>');
}
